package com.dhj.yygh.common.utils;

import com.dhj.yygh.common.helper.JwtHelper;

import javax.servlet.http.HttpServletRequest;

// 获取当前用户信息的工具类
public class AuthContextHolder {

    // 获取当前用户的 id
    public static Long getUserId(HttpServletRequest req) {
        String token = req.getHeader("token");

        return JwtHelper.getUserId(token);
    }

    // 获取当前用户的名称
    public static String getUserName(HttpServletRequest req) {

        String token = req.getHeader("token");

        return JwtHelper.getUserName(token);
    }
}
